package chapter1.date.task;
/*
5:6月的第3个星期日是父亲节，由用户输入年份，算出该年的父亲节是哪一天
 */

import java.text.SimpleDateFormat;
import java.util.*;

public class Task5 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat a = new SimpleDateFormat("M月dd日");
        System.out.print("请输入年份：");
        String year;
        while (!(year = input.next()).matches("\\d{4}"))
            System.out.println("输入错误，请重新输入：");
        calendar.set(Calendar.YEAR, Integer.parseInt(year));
        calendar.set(Calendar.MONTH, 5);
        calendar.set(Calendar.DAY_OF_WEEK_IN_MONTH, 3);
        calendar.set(Calendar.DAY_OF_WEEK, 1);
        System.out.println(Integer.parseInt(year) + "年的父亲节为" + a.format(calendar.getTime()));


    }
}
